﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<IList<MethodInfo>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Method List - Open API Control Panel
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <fieldset>
        <legend>Method Manage &gt; Method List</legend>
        <table border="0" cellpadding="0" cellspacing="0" width="100%">
            <tr>
                <td width="240">
                    <strong>Method Name</strong>
                </td>
                <td width="160" align="center">
                    <strong>Method Function</strong>
                </td>
                <td width="50" align="center">
                    <strong>Used</strong>
                </td>
                <td width="100" align="center">
                    <strong>Arguments</strong>
                </td>
                <td align="center">
                    <strong>Manage</strong>
                </td>
            </tr>
            <%
                foreach (MethodInfo method in Model)
                {
            %>
            <tr>
                <td>
                    <%= method.METHOD_NAME%>
                </td>
                <td align="center">
                    <%= method.METHOD_TEXT%>
                </td>
                <td align="center">
                    <%= method.USED_YN%>
                </td>
                <td align="center">
                    [<%= Html.ActionLink("UnSign", "UnSignArguments", "Method", new { id = method.METHOD_NAME }, new { @title="Un Sign Arguments"})%>]
                    [<%= Html.ActionLink("Sign", "SignArguments", "Method", new { id = method.METHOD_NAME }, new { @title = "Sign Arguments" })%>]
                </td>
                <td align="center">
                    [<%= Html.ActionLink("Modify", "Mod", "Method", new { id = method.METHOD_NAME }, null)%>]
                    [<a href="javascript:void(0);" onclick="javascript:Delete('<%=method.METHOD_NAME %>');">Delete</a>]
                </td>
            </tr>
            <%
                }
            %>
        </table>
        <input type="button" id="btnAdd" name="btnAdd" value="Add Method" />
    </fieldset>

    <script type="text/javascript" language="javascript">

        $().ready(function() {
            $("#btnAdd").click(function() {
                location.href = "/Method/Add";
            })
        })

        function Delete(method_name) {
        
            if (confirm('Are you sure delete?')) {
               
                $.post("/Method/AjaxDel?" + new Date(), {
                    Action: "post",
                    method_name: method_name
                }, function(result) {
                    if (result.FLAG) {
                        alert(result.DESC);
                        location.href = "/Method/List";
                    }
                    else {
                        alert(result.DESC);
                    }
                })
            }
        }
    </script>
    
</asp:Content>
